/**
 *       Copyright (c) 2012 Lukas Zaruba
 *
 *   This file is part of Robot Playground.
 *
 *   Robot Playground is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   Robot Playground is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with Robot Playground. If not, see <http://www.gnu.org/licenses/>.
 */
package net.zarubsys.robotplayground.core.monitors;

import java.util.List;

import net.zarubsys.robotplayground.core.Environment;
import net.zarubsys.robotplayground.core.device.IDevice;
import net.zarubsys.robotplayground.core.modules.IModule;
import net.zarubsys.robotplayground.core.modules.IModuleConfiguration;
import net.zarubsys.robotplayground.core.modules.INotificationCause;

/**
 * IMonitor
 * 
 * Implement this interface if you want to provide your own Monitor.
 * 
 * Do not forget to contribute it to the proper extension point.
 * Implementation must provide public non-parametric constructor.
 * 
 * Consult the Developer's Guide for details.
 *
 * @author Lukas Zaruba, lukas.zaruba@gmail.com
 */
public interface IMonitor {
	
	/**
	 * @return list of ids of modules that are required by this monitor to run.
	 */
	List<String> getRequiredModules();
	
	/**
	 * This method will be invoked after instantiation.
	 * 
	 * @param modules list of instances of modules as listed in the result
	 * of {@link #getRequiredModules()} method.
	 * @param env instance of the environment shared between all objects of this running session
	 */
	void init(List<IModule<? extends IDevice, ? extends IModuleConfiguration>> modules, Environment env);
	
	/**
	 * This method is invoked once any module raises a notification
	 * Implementation might ignore notifications or react only to some of them
	 * 
	 * @param module instance of the module which is raising the notification
	 * @param cause cause of the notification
	 */
	void notify(IModule<?, ?> module, INotificationCause cause);
	
	/**
	 * @return unique id of this module. Be really unique.
	 */
	String getId();
	
	/**
	 * This method can be used to register to the monitor as a listener
	 * What the notifications will be and if this method will be somehow implemented
	 * depends on the needs of each Monitor.
	 */
	void registerMonitorListeners(List<IMonitorListener> listeners);

}

